package com.linsen.core.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/** 操作系统类型 */
@Getter
@AllArgsConstructor
public enum OsTypeEnum {
    WINDOWS("windows","Windows"),
    MAC("mac","Mac"),
    UNIX("x11","Unix"),
    ANDROID("android","Android"),
    IPHONE("iphone","IPhone"),
    UNKNOWN("unknown","未识别的操作系统"),
    ;

    /** 特征值 */
    @JsonValue
    private String value;
    /** 描述 */
    private String description;

    private static final Map<String, OsTypeEnum> VALUES = new HashMap<>();

    static {
        for (final OsTypeEnum osTypeEnum : OsTypeEnum.values()) {
            OsTypeEnum.VALUES.put(osTypeEnum.getValue(), osTypeEnum);
        }
    }

    @JsonCreator
    public static OsTypeEnum getByValue(String value) {
        return OsTypeEnum.VALUES.get(value);
    }

    public String value() {
        return this.value;
    }
    public String description() {
        return this.description;
    }
}
